package com.yzx.lifeassistants.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

import com.yzx.lifeassistants.R;
import com.yzx.lifeassistants.base.BaseActivity;
import com.yzx.lifeassistants.bean.OfficeInform;
import com.yzx.lifeassistants.utils.LogcatUtils;
import com.yzx.lifeassistants.utils.ToastUtils;

/**
 * @Description: 教务处新通知
 * @author: yzx
 * @time: 2016-4-23 下午8:07:37
 */
public class NewOfficeInfoActivity extends BaseActivity implements
		OnClickListener {

	private ImageButton backBtn;// 返回按钮
	private TextView titleTV;// 标题
	private TextView timeTV;// 时间
	private TextView contentTV;// 内容

	private OfficeInform info;// 信息

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_new_office_info);
		init();
		initView();
		setListener();
		initData();
	}

	/**
	 * 
	 * @Description: 初始化
	 */
	private void init() {
		Intent intent = getIntent();
		if (null == intent) {
			showToast("获取异常~", false);
		} else {
			info = (OfficeInform) intent.getSerializableExtra("newOfficeInfo");
			LogcatUtils.i(info.getTitle() + " " + info.getDate() + " "
					+ info.getDetail());
		}
	}

	/**
	 * 
	 * @Description: 初始化控件
	 */
	private void initView() {
		backBtn = (ImageButton) findViewById(R.id.new_office_info_back_btn);
		titleTV = (TextView) findViewById(R.id.new_office_info_title_tv);
		timeTV = (TextView) findViewById(R.id.new_office_info_time_tv);
		contentTV = (TextView) findViewById(R.id.new_office_info_content_tv);
	}

	/**
	 * 
	 * @Description: 设置监听
	 */
	private void setListener() {
		backBtn.setOnClickListener(this);
	}

	/**
	 * 
	 * @Description: 初始化数据
	 */
	private void initData() {
		if (null == info) {

		} else {
			titleTV.setText(info.getTitle());
			timeTV.setText(info.getDate());
			contentTV.setText(info.getDetail());
		}
	}

	/**
	 * 
	 * @Description: 按键监听
	 */
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.new_office_info_back_btn: {// 返回
			finish();
			break;
		}

		default:
			break;
		}
	}

	/**
	 * 
	 * @Description: Toast显示信息
	 */
	private void showToast(String message, Boolean isInfo) {
		if (isInfo) {
			ToastUtils
					.showInfoToast(this, message, R.id.new_office_info_top_ll);
		} else {
			ToastUtils.showAlertToast(this, message,
					R.id.new_office_info_top_ll);
		}

	}
}
